package org.dromara.system.utils;

import lombok.experimental.UtilityClass;
import org.dromara.common.redis.common.RedisConstants;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.system.domain.SysSystem;

import java.util.Date;

@UtilityClass
public class DataStatusUtils {

    public SysSystem getInfo(String ip)
    {
        String key = RedisConstants.SERVICE_DATA_PREFIX + ip;
        SysSystem cacheObject = RedisUtils.getCacheObject(key);
        if (cacheObject==null){
            cacheObject=new SysSystem();
            cacheObject.setStatus(1);
            cacheObject.setDescription("正常");
        }
        return cacheObject;
    }

    public void setJxzServerStatus(String ip,int status)
    {
        String key = RedisConstants.SERVICE_PREFIX + ip;
        SysSystem cacheObject = new SysSystem();
        cacheObject.setStatus(status);
        cacheObject.setIp(ip);
        cacheObject.setUpdateTime(new Date());
        RedisUtils.setCacheObject(key,cacheObject);
    }


}


